
package com.csz.model;

import com.csz.dao.Persistencia;
import java.awt.Image;
import java.io.Serializable;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/* @author Arthur F. Zanona */

public class CategoriaItem extends Persistencia {
    private static final long serialVersionUID = 1L;
    
    private String caiNome;    
    private String caiDescricao;    

    public CategoriaItem() {
    }

    public CategoriaItem(Integer caiId) {
        this.id = caiId;
    }

    public CategoriaItem(Integer caiId, String caiNome) {
        this.id = caiId;
        this.caiNome = caiNome;
    }


    public String getNome() {
        return caiNome;
    }

    public void setNome(String caiNome) {
        this.caiNome = caiNome;
    }

    public String getDescricao() {
        return caiDescricao;
    }

    public void setDescricao(String caiDescricao) {
        this.caiDescricao = caiDescricao;
    }

    public Integer salvar(Object obj) {
        return null;
    }

    @Override
    public void salvar() {
        String namedQuery = this.getId() == null ? Inserir : Atualizar ;
        //----- params aqui
        List<Object> params = new ArrayList<Object>();
        //---- fim params
        if ( this.getId() != null ) params.add( this.getId() );
        PreparedStatement ps = createStatementNamedQuery(namedQuery, params);
        try {
            ps.execute();
        } catch (SQLException ex) {}
    }

    public static Object consultar(Integer id) {
        return CategoriaItem.consultarNamedQuery(ConsultarPorId, Arrays.asList(new Object[]{id}));
    }

    @Override
    public void remover() {
        PreparedStatement ps = createStatementNamedQuery(Remover, Arrays.asList( new Object[] { this.getId() } ));
        try {
            ps.execute();
        } catch (SQLException ex) {}
    }


    public static List<Object> consultar(){
        return CategoriaItem.consultarNamedQuery(ConsultarTodos, Arrays.asList(new Object[]{}));
    }

    public static List<Object> consultarNamedQuery(String namedQuery, List params){
        return null;
    }

    // QUERY SQL --------------------------------------------------------------------------------------------------------------
    public static final String ConsultarTodos  = "SELECT usu_id,usu_login,usu_pass FROM usuario";
    public static final String ConsultarPorId = "SELECT * FROM categoria_item_imagem.. WHERE .._id = ?";
    public static final String ConsultarImagemPath = "CALL consultar_categoria_imagem_path(?,?)";
    private static final String Remover = "DELETE FROM .. WHERE .._id = ?";
    private static final String Atualizar = "UPDATE .. SET .. ";
    private static final String Inserir = "INSERT INTO .. (..) VALUES (?,?,..)";
    // FIM QUERY SQL --------------------------------------------------------------------------------------------------------------



}
